#pragma once
#include "kernel/feSmartPtr.h"
#include "kernel/fePolyline.h"
#include "mfMesh.h"
#include "ZtaskHelper.h"


struct ConductiveLayer;
class feMeshFunction;

class mfAddFuncCalcTask
{
	feSharedPtr<mfMesh>		DistMesh;
	feSimple1dMeshFunction *DistFunc;
	ConductiveLayer			*Layers;
	int						NumLayers;
	double					Sigma0;
	double					MaxZ;
	double					M;
	double					TimeCoeff;
	double					FirstTimeStep;
	int						LayersTime;	
	feVector				*X0;
	bool					UseMainField;
	TaskHelper				*Helper;

private:
	bool Load();
	void CalcSigma0();
	void CreateMesh();


public:
	mfAddFuncCalcTask();
	bool Init(ConductiveLayer *iLayers, int iLayersCount, 
				double iTimeCoeff, double iFirstTimeStep, 
				int iLayersTime, double iM, TaskHelper *iHelper, 
				bool iUseMainField = true);
	bool	Solve();
	double	GetDuDt(double iZ, double iTime);
	double	GetU(double iZ, double iTime);
	double  GetDuDz(double iZ, double iTime);
	feMesh * GetMesh()			{ return DistMesh; }
	feMeshFunction * GetFunc()  { return DistFunc; }
	~mfAddFuncCalcTask();


public:
	static bool	CalcMainField();
};
